﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CapaEntidades;
using System.Data;
using System.Data.SqlClient;

namespace CapaDatos
{
    public class datCliente{
        public static entCliente VerficarAcceso02(String prmUser, String prmPass) {
            entCliente objCliente = null;
            SqlCommand cmd = null;
            SqlDataReader dr = null;
            try
            {
                Conexion cn = new Conexion();
                SqlConnection conex = cn.conectar();
                cmd = new SqlCommand("uspVerificarAcceso", conex);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@prmUsuario", prmUser);
                cmd.Parameters.AddWithValue("@prmPassword", prmPass);
                conex.Open();
                dr = cmd.ExecuteReader();
                if (dr.Read()){
                    objCliente = new entCliente();
                    objCliente.idCliente = Convert.ToInt32(dr["idCliente"]);
                    objCliente.RazonSocial = dr["RazonSocial"].ToString();
                    objCliente.direccion = dr["direccion"].ToString();
                    objCliente.Telefono = dr["Telefono"].ToString();
                    objCliente.Usuario = dr["Usuario"].ToString();
                    objCliente.Password = dr["Password"].ToString();
                }
            }
            catch (Exception e){
                objCliente = null;
            }finally {
                cmd.Connection.Close();
            }
            return objCliente;
        }

    }
}

